<!--
* @Description: api - 表单
* @Author: DHL
* @Date: 2022-03-14 17:13:43
 * @LastEditors: DHL
 * @LastEditTime: 2022-09-06 09:42:32
-->
<template>
  <tw-dialog
    v-model="visible"
    :title="title"
    :loading="loading"
    width="500px"
    height="400px"
    @close="handleClose"
  >
    <el-form ref="dbFormRef" :model="dbForm" :rules="rules" label-width="90px">
      <el-form-item label="项目" prop="projectId">
        <el-input
          v-model="commonObj.projectName"
          clearable
          placeholder="请选择所属项目"
          :disabled="true"
        ></el-input>
      </el-form-item>

      <!-- <el-form-item label="父级分组" prop="apiGroupPid">
        <el-input
          v-model="commonObj.parentGroupName"
          clearable
          placeholder="根节点"
          :disabled="true"
        ></el-input>
      </el-form-item> -->

      <el-form-item label="类别" prop="type">
        <el-select v-model="dbForm.type" clearable placeholder="请选择类别">
          <el-option
            v-for="item in commonObj.typeOption"
            :key="`api_type_${item.value}`"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="包名/类名" prop="packagesOrClasses">
        <el-input
          v-model="dbForm.packagesOrClasses"
          type="textarea"
          :rows="3"
          clearable
          placeholder="请输入包名/类名（多个用英文逗号隔开）"
        ></el-input>
      </el-form-item>

      <el-form-item label="示例">
        <span v-if="dbForm.type === '1'"> com </span>
        <span v-else> 类名需要写全路径 </span>
      </el-form-item>
    </el-form>

    <template #footer>
      <el-button @click="handleReset(true)">取 消</el-button>
      <el-button v-if="action === 'add'" type="warning" @click="handleSubmit(true)">
        提交并继续
      </el-button>
      <el-button v-if="action !== 'view'" type="primary" @click="handleSubmit(false)">
        提 交
      </el-button>
    </template>
  </tw-dialog>
</template>

<script src="./useApiForm.ts"></script>

<style scoped lang="scss">
  .el-divider--horizontal {
    margin-top: 0px;
  }
</style>
